<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>取货单管理</title>
<meta name="decorator" content="default" />
<%@include file="/WEB-INF/views/include/dialog.jsp"%>
<script type="text/javascript">
	$(document).ready(
			function() {
				$("#checkedAll").click(function() {
					//try{
					if ($(this).attr("checked") == true || $(this).attr("checked") == 'checked') { //check all
						$("input[name='checkedId']").each(function() {
							$(this).attr("checked", true);
						});
					} else {
						$("input[name='checkedId']").each(function() {
							$(this).attr("checked", false);
						});
					}
					//}catch(e){
					//alert(e.description+e.name+e.message)
					//}
				});
				$("#btnFenPai").click(
						function() {
							var ckd = $("#checkedAll").attr("checked");
							var ids = "";
							var count = 0;
							var html = "";
							if (ckd == true || ckd == 'checked') { //check all
								$("input[name='checkedId']").each(function() {
									count++;
									var $td = $(this).parents("tr").find("td");
									html += '<div>' + $td.eq(1).text() + '</div>';
									ids += $(this).val() + ",";
								});
							} else {
								$("input[name='checkedId']:checked").each(function() {
									count++;
									html += '<div>[' + $(this).parents("tr").find("td").eq(1).text() + ']</div>';
									ids += $(this).val() + ",";
								});

							}
							if (ids != "") {
								$("#qhdIds").val(ids.substring(0, ids.length - 1));
								$("#fenpaiContent").html(html);
							}
							$.jBox($("#fenpaiBox").html(), { title : "取货单分派", buttons : { "关闭" : true },
								bottomText : "取货单单数：" + count + "条" });
						});
			});

	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
</script>
</head>
<body>
	<div id="fenpaiBox" class="hide">
		<form id="fenpaiForm" action="${ctx}/order/quHuoDan/fenpai" method="post" class="form-horizontal">
			<input id="qhdIds" name="qhdIds" type="hidden" value="">
			<div id="fenpaiContent"></div>
			<select id="userId" name="userId">
				<option value=""></option>
				<c:forEach items="${userList }" var="user">
					<option value="${user.id }">${user.name }</option>
				</c:forEach>
			</select> <br /> <input type="submit" class="btn btn-primary" value="分派" />
		</form>
	</div>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/order/quHuoDan/">取货单列表</a></li>
		<shiro:hasPermission name="order:quHuoDan:edit">
			<li><a href="${ctx}/order/quHuoDan/form">取货单添加</a></li>
		</shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="quHuoDan" action="${ctx}/order/quHuoDan/" method="post"
		class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}" />
		<label>单号 ：</label>
		<form:input path="no" htmlEscape="false" maxlength="50" class="input-medium" />
		<label>取货档口：</label>
		<form:input path="dangkou" htmlEscape="false" maxlength="50" class="input-medium" />
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" />
			&nbsp;<input id="btnFenPai" class="btn btn-primary" type="button" value="分派" />
			&nbsp;<input id="btnZhengBao" class="btn btn-primary" type="button" value="整包" />
	</form:form>
	<tags:message content="${message}" />
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th width="20"><input id="checkedAll" type="checkbox" name="checkedAll" value="0"></th>
				<th>取货单号</th>
				<th>取货档口</th>
				<th>收货人</th>
				<th>取货人</th>
				<th>包数</th>
				<th>送货方式</th>
				<th>送货渠道</th>
				<th>目的地</th>
				<th>货单状态</th>
				<shiro:hasPermission name="order:quHuoDan:edit">
					<th>操作</th>
				</shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="quHuoDan">
				<tr>
					<td><input type="checkbox" name="checkedId" value="${quHuoDan.id }"></td>
					<td><a href="${ctx}/order/quHuoDan/form?id=${quHuoDan.id}">${quHuoDan.no}</a></td>
					<td>${quHuoDan.dangkou}</td>
					<td>${quHuoDan.shouhuoren}</td>
					<td>${quHuoDan.qhrUser.name}</td>
					<td>${quHuoDan.baoshu}</td>
					<td>${fns:getDictLabel(quHuoDan.shfs, 'order_shfs', '')}</td>
					<td>${fns:getDictLabel(quHuoDan.shqd, 'order_shqd', '')}</td>
					<td>${quHuoDan.mudidi}</td>
					<td>${fns:getDictLabel(quHuoDan.delFlag, 'order_qhd_flag', '')}</td>
					<shiro:hasPermission name="order:quHuoDan:edit">
						<td><c:choose>
								<c:when test="${quHuoDan.delFlag eq '2' }">
									<a href="${ctx}/order/quHuoDan/heduiForm?id=${quHuoDan.id}">核对</a>
								</c:when>
								<c:otherwise>
									<a href="${ctx}/order/quHuoDan/form?id=${quHuoDan.id}">修改</a>
								</c:otherwise>
							</c:choose> <a href="${ctx}/order/quHuoDan/delete?id=${quHuoDan.id}" onclick="return confirmx('确认要删除该取货单吗？', this.href)">删除</a></td>
					</shiro:hasPermission>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
